package com.wwg.market.ui.service.interfaces;

import com.wwg.market.ui.service.dto.CategoryDto;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2011-11-22
 * Time: 18:33:19
 * To change this template use File | Settings | File Templates.
 */
public class CategoryServiceImpl implements CategoryService {
    public List<CategoryDto> getAllCategory() {
        List caList = new ArrayList();
        for (int i = 0; i < 20; i++) {
            CategoryDto dto = new CategoryDto();
            dto.setName("栏目" + i);
            dto.setId(new Long(i));
            caList.add(dto);
        }
        return caList;
    }

    public CategoryDto saveAndUpdate(CategoryDto dto) {
        if (dto.getId() == null) {
            CategoryDto dto2 = new CategoryDto();
            dto2.setId(new Long((long) (Math.random() * 1000)));
            dto2.setName(dto.getName());
            dto2.setCode(dto.getCode());
            dto2.setDescription(dto.getDescription());
            return dto2;
        } else
            return dto;
    }

    public void delete(CategoryDto dto) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    public List<CategoryDto> moveCategoryList(CategoryDto dto, List cds) {

        return cds;  
    }
}
